package eaxm;

/**
 * @Auther:小陈的Java
 * 工厂设计模式
 */
abstract class Animal {
    public abstract void eat();
    public abstract void action();
}
abstract class Factory{
    public abstract Animal Life();
}
class Cat extends Animal{

    @Override
    public void eat() {
        System.out.println("猫吃猫粮");
    }

    @Override
    public void action() {
        System.out.println("猫抓老鼠");
    }
}
class Dog extends Animal{

    @Override
    public void eat() {
        System.out.println("狗吃骨头");
    }

    @Override
    public void action() {
        System.out.println("狗在拆家");
    }
}
class CatFactory extends Factory{

    @Override
    public Animal Life() {
        return new Cat();
    }
}
class DogFactory extends Factory{

    @Override
    public Animal Life() {
        return new Dog();
    }
}
public class Number10{
    public static void main(String[] args) {
        CatFactory catFactory = new CatFactory();
        catFactory.Life().action();
        catFactory.Life().eat();
        DogFactory dogFactory = new DogFactory();
        dogFactory.Life().eat();
        dogFactory.Life().action();
    }
}